/*============================================================================*/
/*                         The Freescale Cup                                 */
/*============================================================================*/
/*                        OBJECT SPECIFICATION                                */
/*============================================================================*
* %name:            %	APPUart.c
* %version:         %	1.1
* %created_by:      %   Oscar Rodea Aragon
* %date_created:    %   Sun Aug 26 09:20:00 2012 
*=============================================================================*/
/* DESCRIPTION : Contains applications that use the TRK-MPC5604B UART         */
/*============================================================================*/
/* FUNCTION COMMENT : comment here										      */
/*                                                                            */
/*                                                                            */
/*============================================================================*/
/*                               OBJECT HISTORY                               */
/*============================================================================*/
/*  REVISION |   DATE      |                               |      AUTHOR      */
/*----------------------------------------------------------------------------*/
/*  1.0      | 26/08/2012  |                               | Oscar Rodea      */
/*  1.1      | 01/10/2012 |                               | Andres Torres     */
/* Application using UART to show the scheduler working                       */
/*============================================================================*/

/* Includes */
/* -------- */
#include "stdtypedef.h"
#include "HAL_UART.h"
#include "APPUart.h"
//#include "APP_Linear_Camera.h"

/* Functions macros, constants, types and datas         */
/* ---------------------------------------------------- */
/* Functions macros */

/*==================================================*/ 
/* Definition of constants                          */
/*==================================================*/ 


/*======================================================*/ 
/* Definition of RAM variables                          */
/*======================================================*/ 
//extern T_UBYTE ub_Bin_Pixels[NUM_PIXELS];

extern T_UBYTE ub_Left_Corner;
extern T_UBYTE ub_Right_Corner;

extern T_UBYTE ub_Black_Strip_Width;
extern T_UBYTE ub_Black_Strip_Center;

/*======================================================*/ 
/* close variable declaration sections                  */
/*======================================================*/ 

/* Private defines */

/* Private functions prototypes */
/* ---------------------------- */

/* Exported functions prototypes */
/* ----------------------------- */

/**************************************************************
*  Name                 : APP_UART_Send_LinearCamera_Pixels
*  Description          : Prepare UART application.
						  This function initialize UART at 9600
*  Parameters           :  none
*  Return               :  none
*  Critical/explanation :  No
**************************************************************/

void APP_UART_Send_LinearCamera_Pixels(void)
{
	T_UBYTE i;
	
	//Send bin pixels through the serial port.
	/*for(i = 0; i <NUM_PIXELS; i++)
	{	
		vfnSend_ascii_number_no_protocol(ub_Bin_Pixels[i]);
	}*/
	
	//Send a space.
	vfnSend_byte_no_protocol('\n');
	
	//Send a car return.
	vfnSend_byte_no_protocol(13);
	
	//Send borders of the line.
	/*vfnSend_ascii_number(ub_Left_Corner);
	vfnSend_byte_no_protocol(' ');
	vfnSend_ascii_number(ub_Right_Corner);
	
	//Send a space.
	vfnSend_byte_no_protocol('\n');
	
	//Send a car return.
	vfnSend_byte_no_protocol(13);
	
	//Send with of the line.
	vfnSend_ascii_number(ub_Black_Strip_Width);
	
	//Send a space.
	vfnSend_byte_no_protocol('\n');
	
	//Send a car return.
	vfnSend_byte_no_protocol(13);
	
	//Send center of the line.
	vfnSend_ascii_number(ub_Black_Strip_Center);
	
	//Send a space.
	vfnSend_byte_no_protocol('\n');
	
	//Send a car return.
	vfnSend_byte_no_protocol(13);*/
}

/**************************************************************
*  Name                 : APP_UART_init
*  Description          : Prepare UART application.
						  This function initialize UART at 9600
*  Parameters           :  none
*  Return               :  none
*  Critical/explanation :  No
**************************************************************/
void APP_UART_init(void)
{
	vfnInit_UART();
	
}


/**************************************************************
*  Name                 : APP_UART_SendSensors_app
*  Description          : Send sensors
*  Parameters           :  none
*  Return               :  none
*  Critical/explanation :  No
**************************************************************/
void APP_UART_SendSensors_app(void)
{
	vfnSend_Sensors();

}

/**************************************************************
*  Name                 : APP_UART_SendSensorsAdv_app
*  Description          : Send advance sensors
*  Parameters           :  none
*  Return               :  none
*  Critical/explanation :  No
**************************************************************/
void APP_UART_SendSensorsAdv_app(void)
{
	
	vfnSend_SensorsAdvance();
}

/**************************************************************
*  Name                 : APP_UART_SendByte_app
*  Description          : Send a dummy byte 
*  Parameters           :  none
*  Return               :  none
*  Critical/explanation :  No
**************************************************************/
void APP_UART_SendByte_app(void)
{
	vfnSend_byte(0x55);
	
}

/**************************************************************
*  Name                 : APP_UART_CheckNewInstruction_app
*  Description          : Check if a new instruction is available
*  Parameters           :  none
*  Return               :  none
*  Critical/explanation :  No
**************************************************************/
void APP_UART_CheckNewInstruction_app(void)
{
	vfnRx_NewInstruction();
	
}



/**************************************************************
*  Name                 : APP_UART_Interrupt_app
*  Description          : Save a value received
*  Parameters           :  T_UBYTE ub_RxValue
*  Return               :  none
*  Critical/explanation :  No
**************************************************************/
void APP_UART_Interrupt_app(T_UBYTE ub_RxValue)
{
	vfnReceive_DataFromInterrupt (ub_RxValue);
}
